/*  
 * Copyright 2007 MBARI 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.mbari.timeline.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import com.domainlanguage.time.Duration;
import com.domainlanguage.time.TimePoint;

/** 
 * @author Andrew Chase
 */
public class Event{
	private TimePoint startupTime;
	private Duration duration;
	private final PropertyChangeSupport changeSupport;
	private String name;
	
	public Event(){
		changeSupport = new PropertyChangeSupport(this);
	}

	public void setTime(TimePoint timePoint) {
		TimePoint oldTime = startupTime;
		startupTime = timePoint;
		changeSupport.firePropertyChange("time", oldTime, startupTime);
	}

	public TimePoint getTime() {
		return startupTime;
	}

	public Duration getDuration() {
		return duration;
	}

	public void setDuration(Duration duration) {
		Duration old = this.duration;
		this.duration = duration;
		changeSupport.firePropertyChange("duration", old, duration);
	}
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String oldName = this.name;
		this.name = name;
		changeSupport.firePropertyChange("name", oldName, name);
	}

	/************* changeSupport delegate methods*************************/
	public void addPropertyChangeListener(String string, PropertyChangeListener listener) {
		changeSupport.addPropertyChangeListener(string, listener);
	}


	public void addPropertyChangeListener(PropertyChangeListener arg0) {
		changeSupport.addPropertyChangeListener(arg0);
	}

	public PropertyChangeListener[] getPropertyChangeListeners() {
		return changeSupport.getPropertyChangeListeners();
	}

	public PropertyChangeListener[] getPropertyChangeListeners(String arg0) {
		return changeSupport.getPropertyChangeListeners(arg0);
	}

	public boolean hasListeners(String arg0) {
		return changeSupport.hasListeners(arg0);
	}

	public void removePropertyChangeListener(PropertyChangeListener arg0) {
		changeSupport.removePropertyChangeListener(arg0);
	}

	public void removePropertyChangeListener(String arg0, PropertyChangeListener arg1) {
		changeSupport.removePropertyChangeListener(arg0, arg1);
	}

}